package com.csj.demo.controller;


import com.csj.demo.dao.EmployeeDao;
import com.csj.demo.domain.Employee;
import com.csj.demo.service.EmployeeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController

public class EmployeeController {

    @Autowired
    EmployeeServiceImpl employeeService;

    @Autowired
    EmployeeDao employeeDao;
    @RequestMapping("/employees")
    public List<Employee> selectAll(){
        return employeeService.SelectAll();
    }
    @RequestMapping("/add")
    public String  add(Employee employee){
        if(employeeService.add(employee)){
            return "ok";
        }
        return "false";
    }
    @RequestMapping("/delete")
    public String  delete(int id){
        if(employeeService.delete(id)){
            return "ok";
        }
        return "false";
    }
    @RequestMapping("/update")
    public String  update(Employee employee){
        if(employeeService.update(employee)){
            return "ok";
        }
        return "false";
    }
}
